package com.sunda.spmsoversea.mapper;

import com.sunda.spmsoversea.entity.OverseaWhsOutDtl;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 出库任务表明细 Mapper 接口
 * </p>
 *
 * @author Wayne
 * @since 2021-09-22
 */
@Mapper
public interface OverseaWhsOutDtlMapper extends BaseMapper<OverseaWhsOutDtl> {

    @Select("SELECT OWOD.AUTO_ID_WHS_OUT_DTL AS \"autoIdWhsOutDtl\",\n" +
            "       OWOD.UUID_WHS_OUT AS \"uuidWhsOut\",\n" +
            "       OWOD.ITEM AS \"item\",\n" +
            "       OWOD.WERKS AS \"werks\",\n" +
            "       OWOD.WORKSHOP_CODE AS \"workshopCode\",\n" +
            "       OWOD.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "       OWOD.MATERIAL_NO AS \"materialNo\",\n" +
            "       SAP.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "       SAP.MATERIAL_EN_DESC AS \"materialZhDesc\",\n" +
            "       OWOD.ISSUE_QTY_BASIC_UNIT AS \"issueQtyBasicUnit\",\n" +
            "       OWOD.ACTUAL_QTY_BASIC_UNIT AS \"actualQtyBasicUnit\",\n" +
            "       OWOD.BASIC_UNIT AS \"basicUnit\",\n" +
            "       OWOD.ISSUE_QTY_UNIT_SALES AS \"issueQtyUnitSales\",\n" +
            "       OWOD.ACTUAL_QTY_UNIT_SALES AS \"actualQtyUnitSales\",\n" +
            "       OWOD.UNIT_SALES AS \"unitSales\",\n" +
            "       OWOD.REMARKS AS \"remarks\",\n" +
            "       OWOD.STORAGE_INFO AS \"storageInfo\",\n" +
            "       SAP.NUMERATOR AS \"numerator\",\n" +
            "       SAP.DENOMINATOR AS \"denominator\"\n" +
            "FROM OVERSEA_WHS_OUT_DTL OWOD\n" +
            "    LEFT JOIN MATERIAL_SAP SAP ON OWOD.MATERIAL_NO = SAP.MATERIAL_NO\n" +
            "WHERE OWOD.UUID_WHS_OUT = #{uuidWhsOut} " +
            "ORDER BY OWOD.ITEM ASC ")
    List<Map<String, Object>> getOverseaWhsOutDtlListMap(@Param("uuidWhsOut") String uuidWhsOut);
}
